local mt = ac.skill['棒击大地-原版']
mt.model1 = [[305b51f6a5a494e37d314efc88e74b49.mdx]]

function mt:on_cast_shot()
    self:on_shot(self.target)
end

function mt:on_shot(target)
    local hero = self.owner
    local point1 = hero:get_point()
    local point2 = target:get_point()
    local angle = point1 / point2
    point1:effect{
        model = self.model1,
        size = 0.5,
        angle = angle,
    }
    hero:line_damage(point1,angle,1200,150,self.damage,self,function(unit)
        unit:add_buff '晕眩'{time = 1}
    end)
end

local mt = ac.skill['棒击大地']
mt.temp = '攻击触发'
mt.odds = 15

function mt:on_run(hero,target)
    local hero = self.owner
    local temp = hero:add_skill('棒击大地-原版','隐藏')
    temp.damage = hero:get('攻击') * self.data1/100
    temp:on_shot(target)
end


local mt = ac.skill['猴子猴孙']
mt.area = 800
mt.model1 = [[287.mdl]]
function mt:on_cast_shot()
    local hero = self.owner
    local point = hero:get_point()
    local attr = hero:add('护甲加成',50)
    ac.wait(10*1000,function()
        attr()
    end)
    point:effect
    {
        model = self.model1,
        size = 800/1000,
        time = 10,
    }
    for a=1,2 do
        local sum = a*5
        for b=1,a*5 do
            local p = point - {b*360/sum,a*350}
            self:shot_missile(p)
        end
    end
end

local japi = require 'jass.japi'
function mt:shot_missile(p)
    local hero = self.owner
    local ismiss = hero:get_slk('weapTp1')=='missile'
    local name = '近战单位'
    if ismiss then
        name = '远程单位'
    end
    ac.mover('point'){
        start = hero,
        target = p,
        model = hero:get_model(),
        speed = 800,
        on_finish = function(mover)
            local mover = mover.mover
            mover:set_visible()

            local unit = hero:create_unit(name,p)
            unit:add_restriction '蝗虫'
            unit:add_restriction '定身'
            unit:set_point(p)
            unit:set_height(p:get_height())
            unit:set('攻击距离',200)
            if ismiss then
                local missile = hero:get_slk('Missileart','.mdx')
                local speed = tonumber(hero:get_slk('Missilespeed',900))
                local arc = tonumber(hero:get_slk('Missilearc',0))
                japi.SetUnitMissileArc(unit.handle,arc)
                japi.SetUnitMissileSpeed(unit.handle,speed)
                japi.SetUnitMissileModel(unit.handle,missile)
            end
            unit:set_model(hero:get_model())
            unit:set('攻击间隔',1.1)
            unit:event '单位-拦截造成伤害'(function(_,data)
                data.target:damage{
                    source = hero,
                    common_attack = true,
                    attack = true,
                    damage = hero:get('攻击'),
                    skill = self,
                }
                return true
            end)
            unit:wait(10*1000,function()
                unit:remove()
            end)
        end
    }
end



local mt = ac.skill['钢筋铁骨2']
mt.title = '钢筋铁骨'

function mt:on_add()
    local hero = self.owner
    self.count = 0
    self:gc(ac.loop(200,function()
        local count = (ac.player.online_count - 1) * self.data2 + self.data1
        hero:add('额外护甲',count - self.count)
        self.count = count
    end))
    self:gc(function()
        hero:add('额外护甲',-self.count)
    end)
end

